using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using GenerateP4SpecForm.Enums;

namespace GenerateP4SpecForm.Test.Enums
{
    /// <summary>
    /// Summary description for EnumHelperTest
    /// </summary>
    [TestClass]
    public class EnumHelperTest
    {
        public EnumHelperTest()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void GetName()
        {
            Mode mode = Mode.Update;
            Assert.Equals(EnumHelper.GetName(mode), "Update");
        }

        [TestMethod]
        public void GetEnumFromName_Match()
        {
            string modeName = "APPEND";
            Mode mode = EnumHelper.GetEnumFromName<Mode>(modeName);
            Assert.Equals(mode, Mode.Append);
        }

        [TestMethod]
        public void GetEnumFromName_NoMatch()
        {
            string modeName = "horse";
            Mode mode = EnumHelper.GetEnumFromName<Mode>(modeName);
            Assert.Equals(mode, Mode.Null);
        }

        [TestMethod]
        public void GetEnumFromName_ExactCaseMatch()
        {
            string modeName = "Write";
            Mode mode = EnumHelper.GetEnumFromName<Mode>(modeName, false);
            Assert.Equals(mode, Mode.Write);
        }

        [TestMethod]
        public void GetEnumFromName_ExactCaseNoMatch()
        {
            string modeName = "WRITE";
            Mode mode = EnumHelper.GetEnumFromName<Mode>(modeName, false);
            Assert.Equals(mode, Mode.Null);
        }
    }
}
